/* ----------------------------------------------------------------------
*
* Copyright (C) 2025 XiaoFei. All rights reserved.
*
* $file:		XiaoZhi_MQ2.h
* $Date:        31-January-2025
* $Revision: 	V1
* $Project: 	XiaoFei BSP Library
* $Taobao:      https://item.taobao.com/item.htm?abbucket=17&id=798089372401
*
* -------------------------------------------------------------------- */

#ifndef __XiaoZhi_MQ2_H
#define __XiaoZhi_MQ2_H

#define MQ2_Use_ADC1

#if defined(MQ2_Use_ADC2)||defined(MQ2_Use_ADC1)
    #define MQ2_RCC_AO					RCC_APB2Periph_GPIOA
    #define MQ2_GPIO_AO					GPIOA
    #define MQ2_PIN_AO					GPIO_Pin_1
    #define MQ2_ADC_Channel			    ADC_Channel_1
#endif

#ifdef MQ2_Use_DO
    #define MQ2_RCC_DO					RCC_APB2Periph_GPIOA
    #define MQ2_GPIO_DO					GPIOA
    #define MQ2_PIN_DO					GPIO_Pin_1
    #define MQ2_Trigger				    Bit_RESET
#endif

/* 
* @function: 	MQ2_Init
*/
void MQ2_Init(void);

#if defined(MQ2_Use_ADC2)||defined(MQ2_Use_ADC1)
/* 
* @function: 	MQ2_GetValue
* @return:		The ADC value from MQ-2. This value will be mapped from 0 to 3.3 volts to 0 to 4096.
*/
unsigned int MQ2_GetValue(void);
#endif

#if defined(MQ2_Use_ADC2)||defined(MQ2_Use_ADC1)
/* 
* @function: 	MQ2_GetVoltage
* @return:		The Voltage value from MQ-2. This value need to be limited to 0 to 3.3 volts.
*/
float MQ2_GetVoltage(void);
#endif

#ifdef MQ2_Use_DO
/* 
* @function: 	MQ2_IsTrigger
* @return:		Return 0x01 if the MQ-2 is trigger.
*/
unsigned char MQ2_IsTrigger(void);
#endif

#endif


